#include "grav.h"

output op;  // global variable

int main( int argc, char *argv[] ){
    
    if( argc != 2 ){
        printf("usage:\n");
        printf("    %s cosmo_param.ini\n", argv[0]);
        return 0;
    }

    char inifile[1024];
    sprintf(inifile, "%s", argv[1]);
    
    dictionary *dict = iniparser_load(inifile);

    grav_params *gp = (grav_params*)malloc(sizeof(grav_params));
    ini_grav_params( gp, dict );

    ini_output( &op, dict );

    int k_num       = iniparser_getint(dict, "grav:k_num", 2);
    double k_min    = iniparser_getdouble(dict, "grav:k_min", 1e-4);
    double k_max    = iniparser_getdouble(dict, "grav:k_max", 1.0);
    
    double *k = (double*)malloc(sizeof(double)*k_num);
    double lnk_min  = log(k_min);
    double lnk_max  = log(k_max);
    double dlnk     = (lnk_max-lnk_min)/(k_num-1);
    
    for( int i=0; i<k_num; i++ ){
        k[i] = exp(lnk_min+i*dlnk);
    }

    do_grav_calculation( gp, k, k_num );
    
    free(gp);
    free(k);
    iniparser_freedict(dict);
}
